import request from '@/utils/request'

// 查询成果展示案例列表
export function listCases(query) {
  return request({
    url: '/achievement/cases/list',
    method: 'get',
    params: query
  })
}

// 查询成果展示案例列表(用于官网)
export function homeListCases(query) {
  return request({
    url: '/achievement/cases/homeList',
    method: 'get',
    params: query
  })
}

// 查询成果展示案例详细
export function getCases(id) {
  return request({
    url: '/achievement/cases/' + id,
    method: 'get'
  })
}

// 新增成果展示案例
export function addCases(data) {
  return request({
    url: '/achievement/cases',
    method: 'post',
    data: data
  })
}

// 修改成果展示案例
export function updateCases(data) {
  return request({
    url: '/achievement/cases',
    method: 'put',
    data: data
  })
}

// 删除成果展示案例
export function delCases(id) {
  return request({
    url: '/achievement/cases/' + id,
    method: 'delete'
  })
}

//展示成果案例
export function showCases(data) {
  return request({
    url: '/achievement/cases/showList',
    method: 'get',
    data: data
  })
}

//修改案例发布状态
export function updateCasesStatus(id, isPublished) {
  return request({
    url: '/achievement/cases/publish',
    method: 'post',
    params: {
      id: id,
      isPublished: isPublished  // 现在 isPublished 是 1 或 0（数字）
    }
  })
}

//修改案例精选状态
export function updateCasesFeatured(id, isFeatured) {
  return request({
    url: '/achievement/cases/featured',
    method: 'post',
    params: {
      id: id,
      isFeatured: isFeatured  // 现在 isFeatured 是 1 或 0（数字）
    }
  })
}

//获取已发布的案例
// export function getPublishedCases(params) {
//   return request({
//     url: '/achievement/cases/list',
//     method: 'get',
//     params: {
//       ...params,
//       isPublished: 1  // 只查已发布的
//     }
//   })
// }
